package com.java.threadPool.impl;

import com.java.threadPool.service.AsyncTest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author ：xuelei
 * @date ：Created in 2021/9/23 9:15
 * @description：
 * @modified By：
 * @version: $
 */
@Service
@Slf4j
public class AsyncTestImpl implements AsyncTest {

    private int count = 0;

    @Override
    @Async
    public Integer doTest(int i) {
        test(i);
        log.info("进入接口方法");
        count++;
        return count;
    }

    @Async
    public void test(int i){
        try {
            Thread.sleep(2000);
            log.info("进入业务操作方法"+i);
            log.info("线程名："+Thread.currentThread().getName());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
